<!--头部公共部分-->
{include file="common/header" /}
<div class="x-nav">
      <span class="layui-breadcrumb">
          <a>首页</a><a>学员管理</a><a><cite>学员详情</cite></a>
	  </span>
			<button class="layui-btn layui-btn-xs crumb-reload fr" onclick="location.reload()"><i class="layui-icon layui-icon-refresh"></i></button>
			<a class="layui-btn layui-btn-xs layui-btn-normal crumb-reload fr" href="{:url('Student/lists')}">返回学员管理</a>
</div>
<div class="layui-fluid layadmin-homepage-fluid">
    <div class="layui-row layui-col-space8">
        <div class="layui-col-md4" style="margin-top: 30px;" >
            <div class="layadmin-homepage-panel layadmin-homepage-shadow">
                <div class="layui-card text-center">
                    <div class="layui-col-md6">
                        <div class="layadmin-homepage-pad-ver">
                            <img class="layadmin-homepage-pad-img" src="/img.jpg" width="96" height="96">
                        </div>
                    </div>
                    <div class="layui-col-md6" style="margin-top: 30px;">
                        <div class="layui-card-body">
                            <p class="layadmin-homepage-min-font" style="font-weight:bold;color: #0C0C0C;">{$student.student_name}</p>
                            <p class="layadmin-homepage-min-font">{$student.phone}</p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-row layui-col-space15" style="border-style:solid;border-color: #CCCCCC;border-width: 0 0 1px 0;">
            </div>
            <div class="layui-row layui-col-space15" style="font-size: 12px;">
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">基本信息</div>
                        <div class="layui-card-body">
                            <p class="layadmin-homepage-min-font">性别：<span style="color: #0C0C0C;">{$student.sex}</span></p>
                            <p class="layadmin-homepage-min-font">监护对象：<span style="color: #0C0C0C;">{$student.guardian}</span></p>
                            <p class="layadmin-homepage-min-font">电话号码：<span style="color: #0C0C0C;">{$student.guardian_phone}</span></p>
                            <p class="layadmin-homepage-min-font">课程顾问：<span style="color: #0C0C0C;">{$student.course_consultant}</span></p>
                            <p class="layadmin-homepage-min-font">学员生日：<span style="color: #0C0C0C;">{$student.birth}</span></p>
                            <p class="layadmin-homepage-min-font">学校班级：<span style="color: #0C0C0C;">{$student.school_class}</span></p>
                            <p class="layadmin-homepage-min-font">居住区域：<span style="color: #0C0C0C;">{$student.address}</span></p>
                            <p class="layadmin-homepage-min-font">Q Q：<span style="color: #0C0C0C;">{$student.qq}</span></p>
                            <p class="layadmin-homepage-min-font">微信：<span style="color: #0C0C0C;">{$student.weixin}</span></p>
                            <p class="layadmin-homepage-min-font">英文名：<span style="color: #0C0C0C;">{$student.english_name}</span></p>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">关键信息</div>
                        <div class="layui-card-body">
                            <p class="layadmin-homepage-min-font">报名日期：<span style="color: #0C0C0C;">{$student.sign_up_date}</span></p>
                            <p class="layadmin-homepage-min-font">学员积分：<span style="color: #0C0C0C;"></span></p>
                            <p class="layadmin-homepage-min-font">账户余额：<span style="color: #0C0C0C;">{$student.storedvalue}元</span></p>
                            <p class="layadmin-homepage-min-font">个人中心：<span style="color: #0C0C0C;"></span></p>
                            <p class="layadmin-homepage-min-font">跟进状态：<span style="color: #0C0C0C;" class="follow_up_text">{$student.follow_up_text}</span></p>
                            <p class="layadmin-homepage-min-font">来源：<span style="color: #0C0C0C;" class="channel">{$student.channel}</span></p>
                            <p class="layadmin-homepage-min-font">意向课程：<span style="color: #0C0C0C;" class="intentional_course">{$student.intentional_course}</span></p>
                            <p class="layadmin-homepage-min-font">最后跟进：<span style="color: #0C0C0C;" class="date">{$student.date}</span></p>
                            <p class="layadmin-homepage-min-font">最后操作：<span style="color: #0C0C0C;" class="date">{$student.date}</span></p>
                            <p class="layadmin-homepage-min-font">学费余额：<span style="color: #0C0C0C;" class="date">{$student.balance}</span></p>
                            <p class="layadmin-homepage-min-font">介绍人：<span style="color: #0C0C0C;" class="date">{$student.introduction}</span></p>
                            <p class="layadmin-homepage-min-font">登录账号：<span style="color: #0C0C0C;" class="date"></span></p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md8">
            <div class="layui-fluid layadmin-message-fluid">
                <div class="layui-row" style="border-style:solid;border-color: #CCCCCC;border-width: 2px;margin-top: 15px;">
                    <div class="layui-fluid" id="LAY-component-timeline">
                        <div class="layui-col-md12">

                            <div class="layui-tab">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">跟进记录</li>
                                    <li>就读班级</li>
                                    <li>订单记录</li>
                                    <li>评价记录</li>
                                    <div style="float: right;">
                                        <a class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius" data-type="editCustomer">编辑资料</a>
                                        <a class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius" data-type="assignment">转给同事</a>
                                        <a class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius" data-type="">停课</a>
                                        <a class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius" data-type="">结课</a>
                                    </div>
                                </ul>
                                <div class="layui-tab-content">
                                    <div class="layui-tab-item layui-show">
                                        <form class="layui-form" style="margin-top: -20px;">
                                            <input type="hidden" name="student_id" id="student_id" value="{$student.id}">
                                            <input type="hidden" name="campus_id" value="{$student.campus_id}">
                                            <div class="layui-form-item layui-form-text">
                                                <div class="layui-input-block">
                                                    <textarea name="content" placeholder="请输入内容" lay-verify="required" class="layui-textarea content"></textarea>
                                                </div>
                                            </div>
                                            <div class="layui-form-item" style="width: 580px;">
                                                <div class="layui-inline">
                                                    <label class="layui-form-label" style="font-size: 14px;margin-right: -30px;"><span class="x-red">*</span>沟通方式</label>
                                                    <div class="layui-input-inline">
                                                        <select name="mode" lay-search="" lay-verify="required">
                                                            <option value="">沟通方式</option>
                                                            {volist name="data[29]" id="v"}
                                                            <option value="{$v.id}">{$v['name']}</option>
                                                            {/volist}
                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="layui-inline">
                                                    <label class="layui-form-label" style="font-size: 14px;margin-right: -30px;"><span class="x-red">*</span>下次跟进</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" style="width: 190px;" name="next_follow_up_date" id="gj" readonly lay-verify="required" placeholder="下次跟进时间" autocomplete="off" class="layui-input">
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <div class="layui-inline">
                                                    <label class="layui-form-label" style="font-size: 14px;width: 150px;">是否加入成长记录</label>
                                                    <div class="layui-input-inline">
                                                        <input type="radio" name="growth_record" value="1" class="layui-input" title="是"/>
                                                        <input type="radio" name="growth_record" value="0" class="layui-input" title="否" checked/>
                                                    </div>
                                                </div>
                                                <div class="layui-input-block layui-input-right">
                                                    <a class="layui-btn layui-btn-disabled" lay-submit id="content">添加</a>
                                                </div>
                                            </div>
                                        </form>
                                        <div class="layui-row layui-col-space15" style="border-style:solid;margin-bottom:10px;border-color: #CCCCCC;border-width: 0 0 2px 0;">
                                        </div>
                                        <div class="layui-card">
                                            <div class="layui-tab">
                                                <div class="layui-tab-content">
                                                    <div class="layui-tab-item  layui-show">
                                                        <!--<div class="layui-card-header">-->
                                                        <!--<div class="layui-input-block">-->
                                                        <!--<input type="text" name="keywords" placeholder="请输入搜索关键词" autocomplete="off" class="layui-input">-->
                                                        <!--</div>-->
                                                        <!--</div>-->
                                                        <div class="layui-card-body" style="margin-top: 30px;">
                                                            <ul class="layui-timeline" id="addHtml">
                                                                {volist name="logs" id="v"}
                                                                <li class="layui-timeline-item">
                                                                    <i class="layui-icon layui-timeline-axis"></i>
                                                                    <div class="layui-timeline-content layui-text">
                                                                        <h5 class="layui-timeline-title">{$v.time}</h5>
                                                                        <div style="float: left;margin-right: 10px;">
                                                                            <img style="width:40px;height:40px;border-radius:25px;" src="{$v.avatar}">
                                                                        </div>
                                                                        <div style="font-size: 12px;margin-left: 50px;">
                                                                            <p>
                                                                                <span>{$v.type_text}</span><br/>
                                                                                <span style="font-weight: bold;">沟通内容:&nbsp;&nbsp;</span>{$v.content}
                                                                            </p>
                                                                            {if $v.type == 2}
                                                                            <p>
                                                                                {if $v.mode}<span style="font-weight: bold;">沟通方式:&nbsp;&nbsp;</span>{$v.mode}&nbsp;&nbsp;{/if}
                                                                                {if $v.next_follow_up_date}<span style="font-weight: bold;">下次跟进:&nbsp;&nbsp;</span>{$v.next_follow_up_date}&nbsp;&nbsp;{/if}
                                                                                {if $v.growth_record == 1}<a class="layui-btn layui-btn-xs layui-btn-radius layui-btn-normal">成长记录</a>{/if}
                                                                            </p>
                                                                            {/if}
                                                                            <div id="piyueHtml{$v.id}">
                                                                                {volist name="v['marks']" id="mark"}
                                                                                <p style="float: left;margin-right: 10px;">
                                                                                    <img style="width:40px;height:40px;border-radius:5px;" src="{$mark.img}">
                                                                                </p>
                                                                                <p>
                                                                                    <span>{$mark.name}</span><br/>
                                                                                    <span style="font-weight: bold;">批阅:&nbsp;&nbsp;</span>{$mark.marking}
                                                                                    <span style="font-weight: bold;">{$mark.time}&nbsp;&nbsp;</span>
                                                                                </p>
                                                                                {/volist}
                                                                            </div>
                                                                            <p style="margin-right: 20px;float: right;">
                                                                                <a href="javascript:;" style="text-decoration: none;" onclick="piyue(this,{$v.id})">批阅</a>
                                                                            </p>
                                                                            <form style="display: none;" id="{$v.id}">
                                                                                <div class="layui-form-item layui-form-text">
                                                                                    <div class="layui-input-block">
                                                                                        <textarea id="content{$v.id}" placeholder="请输入内容" lay-verify="required" class="layui-textarea content"></textarea>
                                                                                    </div>
                                                                                </div>
                                                                                <div class="layui-form-item">
                                                                                    <div class="layui-input-block layui-input-right">
                                                                                        <input type="hidden" id="id{$v.id}" value="{$v.id}">
                                                                                        <a class="layui-btn layui-btn-xs layui-btn-normal" onclick="submit(this,{$v.id})">提交</a>
                                                                                        <a class="layui-btn layui-btn-xs layui-btn-primary" lay-submit onclick="quxiao(this,{$v.id})">取消</a>
                                                                                    </div>
                                                                                </div>
                                                                            </form>
                                                                        </div>
                                                                    </div>
                                                                </li>
                                                                {/volist}
                                                            </ul>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-tab-item">
                                        <div  class="x-body" class="clear:both;">
                                            <div class="layui-card-header" style="olor:#01AAED;font-weight: bold;">就读班级</div>
                                            <div class="layui-row" style="border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;">
                                                    <div class="layui-input-inline">
                                                        <input type="text" style="width: 180px;" name="grades_name" placeholder="请输入班级名称" autocomplete="off" class="layui-input">
                                                    </div>
                                                    <div class="layui-input-inline">
                                                        <button class="layui-btn" id="attending_classes_search">
                                                            <i class="layui-icon layui-icon-search"></i>筛选</button>
                                                        <button class="layui-btn layui-btn-danger" id="attending_classes_clear">
                                                            <i class="layui-icon"></i>重置</button>

                                                    </div>
                                                <table class="layui-hide" id="Attending_classes"></table>
                                            </div>
                                        </div>
                                        <div  class="x-body" class="clear:both;">
                                            <div class="layui-card-header"style="olor:#01AAED;font-weight: bold;">过往班级</div>
                                            <div class="layui-row" style="border-left:1px solid #e5e5e5;border-right:1px solid #e5e5e5;">
                                                <div class="layui-input-inline">
                                                    <input type="text" style="width: 180px;" name="grades_name_past" placeholder="请输入班级名称" autocomplete="off" class="layui-input">
                                                </div>
                                                <div class="layui-input-inline">
                                                    <button class="layui-btn" id="past_class_search">
                                                        <i class="layui-icon layui-icon-search"></i>筛选</button>
                                                    <button class="layui-btn layui-btn-danger" id="past_class_clear">
                                                        <i class="layui-icon"></i>重置</button>

                                                </div>
                                            </div>
                                            <table class="layui-hide" id="Past_class"></table>
                                        </div>
                                    </div>
                                    <div class="layui-tab-item">

                                        <script>
                                            let Order_json = eval('{$Order_json}');  //订单
                                            let Flow_json = eval('{$Flow_json}');  //流水
                                            let Stored_json = eval('{$Stored_json}');  //储值

                                            for(let i =0; i < Order_json.length; i ++) {
                                                document.write('<ul class="layui-timeline">');
                                                document.write('<li class="layui-timeline-item">');
                                                document.write('<i class="layui-icon layui-timeline-axis">&#xe63f;</i>');
                                                document.write('<div class="layui-timeline-content layui-text">');
                                                document.write('<div  class="x-body" class="clear:both;">');
                                                document.write('<div class="layui-card-header"style="font-size:13px; font-weight: bold;">直接报名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+ Order_json[i].signing_date +'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;订单号&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+ Order_json[i].contract_number +'</div>');
                                                <!-- Tab1 -->
                                                document.write('<table class="layui-table">');
                                                document.write('<thead>');
                                                document.write('<tr>');
                                                document.write('<th style="text-align: center; font-size: 12px">项目</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">单价</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">数量</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">优惠金额</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">赠送</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">应收</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">实收</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">欠收</th>');
                                                document.write('</tr>');
                                                document.write('</thead>');
                                                document.write('<tbody>');
                                                let order_json_item = Order_json[i].order_json;
                                                for(let j =0; j < order_json_item.length; j ++){
                                                    document.write('<tr>');
                                                    document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+order_json_item[j].project_name+'</td>');
                                                    document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+order_json_item[j].project_price+'</td>');
                                                    document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+order_json_item[j].project_nums+'</td>');
                                                    document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+order_json_item[j].project_discount+'</td>');
                                                    document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+order_json_item[j].project_give_nums+'</td>');
                                                    document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+order_json_item[j].project_net_receipts+'</td>');
                                                    document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+order_json_item[j].project_actual+'</td>');
                                                    document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+order_json_item[j].project_arrears+'</td>');
                                                    document.write('</tr>');
                                                }
                                                document.write('</tbody>');
                                                document.write('</table>');

                                                document.write('</div>');
                                                document.write('</div>');
                                                document.write('</li>');
                                                document.write('<li class="layui-timeline-item">');
                                                document.write('<i class="layui-icon layui-timeline-axis">&#xe63f;</i>');
                                                document.write('<div class="layui-timeline-content layui-text">');
                                                document.write('<div  class="x-body" class="clear:both;">');
                                                document.write('<div class="layui-card-header"style="font-size:13px;font-weight: bold;">流水&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+ Flow_json[i].signing_date +'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;订单号&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+ Flow_json[i].contract_number +'</div>');
                                                <!-- Tab2 -->
                                                document.write('<table class="layui-table">');
                                                document.write('<thead>');
                                                document.write('<tr>');
                                                document.write('<th style="text-align: center; font-size: 12px">流水号</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">时间</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">类型</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">结算方式</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">金额</th>');
                                                document.write('<th style="text-align: center; font-size: 12px">备注</th>');
                                                document.write('</tr>');
                                                document.write('</thead>');
                                                document.write('<tbody>');
                                                if(Flow_json.length > 0){
                                                    let flow_json_item = Flow_json[i].flow_json;
                                                    for(let j =0; j < flow_json_item.length; j ++){
                                                        document.write('<tr>');
                                                        document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+flow_json_item[j].flow_number+'</td>');
                                                        document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+flow_json_item[j].flow_time+'</td>');
                                                        document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+flow_json_item[j].flow_type+'</td>');
                                                        document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+flow_json_item[j].flow_payment_method+'</td>');
                                                        document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+flow_json_item[j].flow_amount+'</td>');
                                                        document.write('<td style="text-align: center; background-color: #5FB878; font-size: 10px">'+flow_json_item[j].flow_remark+'</td>');
                                                        document.write('</tr>');
                                                    }
                                                }
                                                document.write('</tbody>');
                                                document.write('</table>');


                                                document.write('</div>');
                                                document.write('</div>');
                                                document.write('</li>');
                                                document.write('<li class="layui-timeline-item">');
                                                document.write('<i class="layui-icon layui-timeline-axis">&#xe63f;</i>');
                                                document.write('<div class="layui-timeline-content layui-text">');
                                                document.write('<div  class="x-body" class="clear:both;">');
                                                document.write('<div class="layui-card-header"style="font-size:13px; font-weight: bold;">储值&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+ Stored_json[i].signing_date +'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;订单号&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+ Stored_json[i].contract_number +'</div>');
                                                <!-- Tab3 -->
                                                document.write('<table class="layui-table">');
                                                document.write('<thead>');
                                                document.write('<tr>');
                                                document.write('<th style="text-align: center; background-color: #5FB878; font-size: 12px">储值总金额</th>');
                                                document.write('<th style="text-align: center; background-color: #5FB878; font-size: 12px">订单储值金额</th>');
                                                document.write('<th style="text-align: center; background-color: #5FB878; font-size: 12px">剩余储值金额</th>');
                                                document.write('</tr>');
                                                document.write('</thead>');
                                                document.write('<tbody>');
                                                if(Stored_json.length > 0){
                                                    let stored_json_item = Stored_json[i].stored_json;
                                                    for(let j =0; j < stored_json_item.length; j ++){
                                                        document.write('<tr>');
                                                        document.write('<td style="text-align: center; font-size: 10px">'+stored_json_item[j].store_total_receipts+'</td>');
                                                        document.write('<td style="text-align: center; font-size: 10px">'+stored_json_item[j].store_net_receipts+'</td>');
                                                        document.write('<td style="text-align: center; font-size: 10px">'+stored_json_item[j].store_surplus_money+'</td>');
                                                        document.write('</tr>');
                                                    }
                                                }
                                                document.write('</tbody>');
                                                document.write('</table>');

                                                document.write('</div>');
                                                document.write('</div>');
                                                document.write('</li>');
                                                document.write('<li class="layui-timeline-item">');
                                                document.write('<i class="layui-icon layui-timeline-axis">&#xe63f;</i>');
                                                document.write('<div class="layui-timeline-content layui-text">');
                                                document.write('<div  class="x-body" class="clear:both;">');
                                                document.write('<div class="layui-card-header"style="color:#01AAED;font-weight: bold;"></div>');
                                                document.write('</div>');
                                                document.write('</div>');
                                                document.write('</li>');
                                                document.write('</ul>');
                                                document.write('<hr class="layui-bg-black">');
                                            }
                                        </script>
                                    </div>
                                    <div class="layui-tab-item">
                                    (暂无任何评价记录)
                                    </div>
                                </div>
                            </div>


                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--底部公共部分-->
{include file="common/footer" /}
<script>
    function quxiao(obj,id){
        $("#"+id+"").hide();
    }

    function piyue(obj,id){
        $("#"+id+"").show();
        $("#content"+id+"").val('');
    }
    function submit(obj,id){
        let content = $("#content"+id+"").val();
        if(content == '' || content == null){
            layer.msg('请输入批阅内容', {icon: 7, time: 2000}, function () {
            });
            return false;
        }
        console.log(id);
        console.log(content);
        $.ajax({
            url: "{:url('Student/marking')}",
            type: 'post',
            dataType: 'json',
            data: {id:id,marking:content},
            success: function (res) {
                if (res.code === 1) {
                    layer.msg(res.msg, {icon: 1, time: res.wait * 1000}, function () {
                        let data = res.data
                        console.log(data);
                        let html = '<p style="float: left;margin-right: 10px;">'
                            +'<img style="width:40px;height:40px;border-radius:5px;" src="'+data.img+'">'
                            +'</p>'
                            +'<p>'
                            +'<span>'+data.name+'</span><br/>'
                            +'<span style="font-weight: bold;">批阅:&nbsp;&nbsp;</span>' +data.marking+ '&nbsp;&nbsp;'
                            +'<span style="font-weight: bold;">'+data.time+'&nbsp;&nbsp;</span>'
                            +'</p>';
                        $("#piyueHtml"+id+"").append(html)
                    });
                    $("#"+id+"").hide();
                } else {
                    layer.msg(res.msg, {icon: 2, time: res.wait * 1000}, function () {
                        // window.location.reload();
                    });
                }
            },
        });
        return false;
    }
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','element', 'rate','form','laydate','table'], function(){
        let rate = layui.rate;
        let form = layui.form;
        let table = layui.table;
        let element = layui.element;
        let laydate = layui.laydate;
        let grade = $("#grade").val();
        let student_id = "{$student.id}";
        let date = "{$date}";
        let loading = layer.load();
        //下次跟进日期
        laydate.render({
            elem: '#gj'
            ,min: date
            ,trigger: 'click'
        });
        //上门日期
        laydate.render({
            elem: '#sm'
            ,min: date
            ,trigger: 'click'
        });

        //数据表格 方法级渲染 就读班级
        let attending_tableIns = table.render({
            elem: '#Attending_classes'
            , url: '{:url("Student/attending_classes")}?id='+student_id
            , method: 'POST'
            , loading: true
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code === 1) {
                    res.code = 0;
                } else {
                    res.code = -1;
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            },
            cols: [[
                {field: 'grades_name', title: '班级名称', style:'background-color: #5FB878; color: #fff; font-size: 10px;', width:180, align: 'center'
                },{field: 'course_type', title: '课程类型',style:'background-color: #5FB878; color: #fff; font-size: 10px;', width: 100, align: 'center'
                },{field: 'sign_up_date', title: '首次报名时间',style:'background-color: #5FB878; color: #fff; font-size: 10px;', width: 120, align: 'center'
                },{field: 'already_grades_class', title: '已上/剩余', style:'background-color: #5FB878; color: #fff; font-size: 10px;',width: 100, align: 'center'
                },{field: 'already_class', title: '总课次/时',style:'background-color: #5FB878; color: #fff; font-size: 10px;', width: 100, align: 'center'
                },{field: 'total', title: '剩余学费(元)',style:'background-color: #5FB878; color: #fff; font-size: 10px;', width: 120, align: 'center'
                },{field: 'headmaster', title: '班主任', style:'background-color: #5FB878; color: #fff; font-size: 10px;',width: 100, align: 'center'
                },{field: 'teacher', title: '任课老师',style:'background-color: #5FB878; color: #fff; font-size: 10px;',  width: 100, align: 'center'
                }
            ]]
            , height: 'full-180'
            , page: true
            , done: function () {
                $('tr').css({'background-color': '#009688', 'color': '#fff'});
                layer.close(loading);
            }
        });

        //数据表格 方法级渲染 过往班级
        let past_tableIns = table.render({
            elem: '#Past_class'
            , url: '{:url("Student/past_class")}?id='+student_id
            , method: 'POST'
            , loading: true
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code === 1) {
                    res.code = 0;
                } else {
                    res.code = -1;
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.message, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data //解析数据列表
                };
            },
            cols: [[
                {field: 'grades_name', title: '班级名称',style:'background-color: #5FB878; color: #fff; font-size: 10px;', width: 100, align: 'center'
                },{field: 'course_type', title: '课程类型',style:'background-color: #5FB878; color: #fff; font-size: 10px;', width: 100, align: 'center'
                },{field: 'sign_up_date', title: '首次报名时间',style:'background-color: #5FB878; color: #fff; font-size: 10px;', width: 150, align: 'center'
                },{field: 'already_grades_class', title: '已上/剩余',style:'background-color: #5FB878; color: #fff; font-size: 10px;', width: 100, align: 'center'
                },{field: 'already_class', title: '总课次/时',style:'background-color: #5FB878; color: #fff; font-size: 10px;', width: 100, align: 'center'
                },{field: 'total', title: '剩余学费(元)',style:'background-color: #5FB878; color: #fff; font-size: 10px;', width: 120, align: 'center'
                },{field: 'headmaster', title: '班主任', style:'background-color: #5FB878; color: #fff; font-size: 10px;',width: 100, align: 'center'
                },{field: 'teacher', title: '任课老师',  style:'background-color: #5FB878; color: #fff; font-size: 10px;',width: 100, align: 'center'
                }
            ]]
            , height: 'full-180'
            , page: true
            , done: function () {
                $('tr').css({'background-color': '#009688', 'color': '#fff'});
                layer.close(loading);
            }
        });



        form.on('submit(formDemo)', function(data){
            $.ajax({
                url: "{:url('Student/addFollowUp')}",
                type: 'post',
                dataType: 'json',
                data: data.field,
                success: function (res) {
                    if (res.code === 1) {
                        layer.msg(res.msg, {icon: 1, time: res.wait * 1000}, function () {
                            //  window.location.reload();
                            let data = res.data
                            console.log(data.growth_record);
                            let html = '';
                            if(data.growth_record == 1){
                                html=  '<li class="layui-timeline-item">'
                                    +'<i class="layui-icon layui-timeline-axis"></i>'
                                    +'<div class="layui-timeline-content layui-text">'
                                    +'<h5 class="layui-timeline-title">'+data.time+'</h5>'
                                    +'<div style="float: left;margin-right: 10px;">'
                                    +' <img style="width:50px;height:50px;border-radius:25px;" src="'+data.avatar+'">'
                                    +'</div>'
                                    +'<div style="font-size: 12px;margin-left: 50px;">'
                                    +'<p>'
                                    +'<span>'+data.type_text+'</span>'
                                    +'<br/>'
                                    +data.content
                                    +'</p>'
                                    +'<p>'
                                    +'<span style="font-weight: bold;">沟通方式:&nbsp;&nbsp;</span>'+data.mode+'&nbsp;&nbsp;'
                                    +'<span style="font-weight: bold;">下次跟进:&nbsp;&nbsp;</span>'+data.next_follow_up_date+'&nbsp;&nbsp;'
                                    +'<a class="layui-btn layui-btn-xs layui-btn-radius layui-btn-normal">成长记录</a>'
                                    +'</p>'
                                    +'<p style="margin-right: 20px;float: right;">'
                                    +'<a href="javascript:;" style="text-decoration: none;" onclick="piyue(this,'+data.student_id+')">批阅</a>'
                                    +'</p>'
                                    +'<form style="display: none;" id="'+data.student_id+'">'
                                    +'<div class="layui-form-item layui-form-text">'
                                    +'<div class="layui-input-block">'
                                    +'<textarea id="content'+data.student_id+'" placeholder="请输入内容" lay-verify="required" class="layui-textarea content"></textarea>'
                                    +'</div>'
                                    +'</div>'
                                    +'<div class="layui-form-item">'
                                    +'<div class="layui-input-block layui-input-right">'
                                    +'<input type="hidden" id="id'+data.student_id+'" value="'+data.student_id+'">'
                                    +'<a class="layui-btn layui-btn-xs layui-btn-normal" onclick="submit(this,'+data.student_id+')">提交</a>'
                                    +'<a class="layui-btn layui-btn-xs layui-btn-primary" lay-submit onclick="quxiao(this,'+data.student_id+')">取消</a>'
                                    +'</div>'
                                    +'</div>'
                                    +'</form>'
                                    +'</div>'
                                    +'</div>'
                                    +'</li>';
                            }else{
                                html=  '<li class="layui-timeline-item">'
                                    +'<i class="layui-icon layui-timeline-axis"></i>'
                                    +'<div class="layui-timeline-content layui-text">'
                                    +'<h5 class="layui-timeline-title">'+data.time+'</h5>'
                                    +'<div style="float: left;margin-right: 10px;">'
                                    +' <img style="width:50px;height:50px;border-radius:25px;" src="'+data.avatar+'">'
                                    +'</div>'
                                    +'<div  style="font-size: 12px;margin-left: 50px;">'
                                    +'<p>'
                                    +'<span>'+data.type_text+'</span>'
                                    +'<br/>'
                                    +data.content
                                    +'</p>'
                                    +'<p>'
                                    +'<span style="font-weight: bold;">沟通方式:&nbsp;&nbsp;</span>'+data.mode+'&nbsp;&nbsp;'
                                    +'<span style="font-weight: bold;">下次跟进:&nbsp;&nbsp;</span>'+data.next_follow_up_date+'&nbsp;&nbsp;'
                                    +'</p>'
                                    +'<p style="margin-right: 20px;float: right;">'
                                    +'<a href="javascript:;" style="text-decoration: none;" onclick="piyue(this,'+data.student_id+')">批阅</a>'
                                    +'</p>'
                                    +'<form style="display: none;" id="'+data.student_id+'">'
                                    +'<div class="layui-form-item layui-form-text">'
                                    +'<div class="layui-input-block">'
                                    +'<textarea id="content'+data.student_id+'" placeholder="请输入内容" lay-verify="required" class="layui-textarea content"></textarea>'
                                    +'</div>'
                                    +'</div>'
                                    +'<div class="layui-form-item">'
                                    +'<div class="layui-input-block layui-input-right">'
                                    +'<input type="hidden" id="id'+data.student_id+'" value="'+data.student_id+'">'
                                    +'<a class="layui-btn layui-btn-xs layui-btn-normal" onclick="submit(this,'+data.student_id+')">提交</a>'
                                    +'<a class="layui-btn layui-btn-xs layui-btn-primary" lay-submit onclick="quxiao(this,'+data.student_id+')">取消</a>'
                                    +'</div>'
                                    +'</div>'
                                    +'</form>'
                                    +'</div>'
                                    +'</div>'
                                    +'</li>';
                            }
                            $('#addHtml').prepend(html)

                        });
                    } else {
                        layer.msg(res.msg, {icon: 2, time: res.wait * 1000}, function () {
                            // window.location.reload();
                        });
                    }
                },
            });
            return false;
        });
        //自定义文本
        rate.render({
            elem: '#test-rate-dome1'
            ,value: grade
            ,text: false
            ,setText: function(value){ //自定义文本的回调
                let arrs = {
                    '1': '1'
                    ,'2': '2'
                    ,'3': '3'
                    ,'4': '4'
                    ,'5': '5'
                };
                console.log(arrs[value]);
            }
        })

        //自定义文本
        rate.render({
            elem: '#test-rate-dome2'
            ,value: ''
            ,text: false
            ,setText: function(value){ //自定义文本的回调
                let arrs = {
                    '1': '1'
                    ,'2': '2'
                    ,'3': '3'
                    ,'4': '4'
                    ,'5': '5'
                };
                console.log(arrs[value]);
                $("#intentional_grade").val(arrs[value]);
            }
        })

        //搜索项
        $('#attending_classes_search').click(function () {
            var field = {};
            field.grades_name = $('input[name=grades_name]').val();
            attending_tableIns.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
        //清除
        $('#attending_classes_clear').click(function () {
            $('.layui-input').each(function (index, element) {
                $(element).val('');
            })
            attending_tableIns.reload({
                where: {
                    'grades_name': '',
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });


        //搜索项
        $('#past_class_search').click(function () {
            var field = {};
            field.grades_name = $('input[name=grades_name_past]').val();
            past_tableIns.reload({
                where: field,
                method: 'POST',
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
        //清除
        $('#past_class_clear').click(function () {
            $('.layui-input').each(function (index, element) {
                $(element).val('');
            })
            past_tableIns.reload({
                where: {
                    'grades_name_past': '',
                },
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

        let active = {
            editCustomer: function () {
                location.href = "{:url('Student/edit')}?id=" + student_id;
            },
            assignment: function () {
                /*转给同事*/
                layer.open({
                    type: 2,
                    skin: 'layui-layer-lan',
                    closeBtn: 2,
                    title: '转给同事',
                    area: ['60%', '400px'],
                    shadeClose: false,
                    btnAlign: 'c',
                    shade: 0,
                    content: "{:url('Student/assignment')}?ids=" + student_id,
                });
            }
        };

        form.on('select(follow_filter)', function(data){
            if(data.value == 36){  //已预约
                document.getElementById("drop_door").style.visibility="visible";
            } else {
                document.getElementById("drop_door").style.visibility="hidden";
            }

        })

        $('.layui-btn').on('click', function () {
            let type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $('body',function () {
            $(this).on('input', '.content', function () {
                let content = $('textarea[name="content"]').val();
                if(content !== ''){
                    $('#content').attr('lay-filter','formDemo');
                    $('#content').removeClass('layui-btn-disabled');
                    return false;
                }
            });
        });
    });
</script>
